package com.uwantsoft.business.service;

import com.uwantsoft.business.facade.dto.parking.ParkOverviewQueryCondition;
import com.uwantsoft.business.service.domain.park.Park;
import com.uwantsoft.business.service.infrastructure.ParkRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author LeiPeichen.
 */
@Service(value = "parkService")
public class ParkServiceImpl {

    @Resource(name = "hibernateParkRepository")
    private ParkRepository parkRepository;

    public int findParkTotalAmount(ParkOverviewQueryCondition condition){
        return parkRepository.findParkTotalAmount(condition);
    }
    public List<Park> findParks(ParkOverviewQueryCondition condition){
        return parkRepository.findParks(condition);
    }

    public void createPark(Park park){
        parkRepository.save(park);
    }

    public Park findPark(String guid){
        return parkRepository.findEntityByGuid(guid, Park.class);
    }

    public Park findParkDetail(String guid) {
        return parkRepository.findEntityByGuid(guid, Park.class);
    }

    public void lockPark(String guid, boolean lock) {
        Park park = parkRepository.findEntityByGuid(guid, Park.class);
        park.active(lock);
    }
}
